package org.oproject.rmi.hessian.core.context;

import java.util.Random;

public class ContextUtil 
{
	private static Random random = new Random();
	
	private static final int APPEND_LENGTH = 8;
	
	/**
	 * 生成唯一的job id
	 * @return
	 */
	public static String generateJobID()
	{
		StringBuffer str = new StringBuffer(String.valueOf(random.nextInt(999999999)));
		if(str.length() > APPEND_LENGTH)
		{
			str = str.delete(APPEND_LENGTH, str.length());
		}
		else
		{
			for(int i = 0; i < APPEND_LENGTH - str.length(); i++)
			{
				str.append(random.nextInt(9));
			}
		}
		return (System.currentTimeMillis() + str.toString());
	}
	
	public static void main(String[] args)
	{
		for(int i=0; i< 10; i++)
		{
			System.out.println(generateJobID());
		}
	}
}
